$def with (catelist, sublist)

<div id="subscribe-list">
  $for cate in catelist:
      <h3>$cate.name</h3>
      <ul>
        $for sub in sublist:
            $if sub['cid'] == cate.cid:
                <li>
                  <input type="checkbox" name="pid" value="$sub['pid']" title="check to subscribe it." $sub['checked'] />
                  <span class="pattern">$sub['pattern']</span>
                  <span class="description">$sub['name']</span>
                </li>
      </ul>
</div>
  
<script type="text/javascript">
$$("#subscribe-list input").click(function(){
    vmail = $$("#email").val();
    vpat = $$(this).val();
    action = ""
    if($$(this).is(":checked")){
        action = "/sub";
    }else{
        action = "/del";
    }
    $$.post(action,
    {
        email: vmail,
        patid: vpat
    },
    function(data){
        msg = "err"
        if(action == "/sub"){
            msg = "Subscribed a pattern";
        }else if(action == "/del"){
            msg = "Deleted a pattern";
        }
        $$("#subscribe-result").html(msg);
    });
});
</script>
